The present invention relates generally to JAVA™ programming environments, and more particularly, to frameworks for generation of JAVA™ macro instructions in JAVA™ computing environments.
One of the goals of high level languages is to provide a portable programming environment such that the computer programs may easily be ported to another computer platform. High level languages such as “C” provide a level of abstraction from the underlying computer architecture and their success is well evidenced from the fact that most computer applications are now written in a high level language.
Portability has been taken to new heights with the advent of the World Wide Web (“the Web”) which is an interface protocol for the Internet that allows communication between diverse computer platforms through a graphical interface. Computers communicating over the Web are able to download and execute small applications called applets. Given that applets may be executed on a diverse assortment of computer platforms, the applets are typically executed by a JAVA™ virtual machine.
Recently, the JAVA™ programming environment has become quite popular. The JAVA™ programming language is a language that is designed to be portable enough to be executed on a wide range of computers ranging from small devices (e.g., pagers, cell phones and smart cards) up to supercomputers. Computer programs written in the JAVA™ programming language (and other languages) may be compiled into JAVA™ Bytecode instructions that are suitable for execution by a JAVA™ virtual machine implementation. The JAVA™ virtual machine is commonly implemented in software by means of an interpreter for the JAVA™ virtual machine instruction set but, in general, may be software, hardware, or both. A particular JAVA™ virtual machine implementation and corresponding support libraries together constitute a JAVA™ runtime environment.
Computer programs in the JAVA™ programming language are arranged in one or more classes or interfaces (referred to herein jointly as classes or class files). Such programs are generally platform, i.e., hardware and operating system, independent. As such, these computer programs may be executed, without modification, on any computer that is able to run an implementation of the JAVA™ runtime environment.
Object-oriented classes written in the JAVA™ programming language are compiled to a particular binary format called the “class file format.” The class file includes various components associated with a single class. These components can be, for example, methods and/or interfaces associated with the class. In addition, the class file format can include a significant amount of ancillary information that is associated with the class. The class file format (as well as the general operation of the JAVA™ virtual machine) is described in some detail in The JAVA™ Virtual Machine Specification. Second Edition,by Tom Lindholm and Frank Yellin, which is hereby incorporated herein by reference.
FIG. 1A shows a progression of a simple piece of a JAVA™ source code 101 through execution by an interpreter, the JAVA™ virtual machine. The JAVA™ source code 101 includes the classic Hello World program written in JAVA™. The source code is then input into a Bytecode compiler 103 that compiles the source code into Bytecodes. The Bytecodes are virtual machine instructions as they will be executed by a software emulated computer. Typically, virtual machine instructions are generic (i.e., not designed for any specific microprocessor or computer architecture) but this is not required. The Bytecode compiler 103 outputs a JAVA™ class file 105 that includes the Bytecodes for the JAVA™ program. The JAVA™ class file 105 is input into a JAVA™ virtual machine 107. The JAVA™ virtual machine 107 is an interpreter that decodes and executes the Bytecodes in the JAVA™ class file. The JAVA™ virtual machine is an interpreter, but is commonly referred to as a virtual machine as it emulates a microprocessor or computer architecture in software (e.g., the microprocessor or computer architecture may not exist in hardware).
FIG. 1B illustrates a simplified class file 100. As shown in FIG. 1B, the class file 100 includes a constant pool 102 portion, interfaces portion 104, fields portion 106, methods portion 108, and attributes portion 110. The methods portion 108 can include, or have references to, several JAVA™ methods associated with the JAVA™ class which are represented in the class file 100.
During the execution of JAVA™ programs, there may often be a need to type check a JAVA™ class against another JAVA™ class. Type checking is performed, for example, during a casting operation when a first reference to a JAVA™ class is set to a second. Casting is valid if the second reference points to the same class or a parent of that class in its class hierarchy. Accordingly, there is a need to determine whether the second reference is of a class type which is a parent of the class referenced by the first reference. Unfortunately, however, this determination can require several operations to be performed. Typically, a field in the internal class representation is reserved to reference the parent of the class (i.e., an internal representation of the parent class). The parent internal representation, in turn, has a field that references an internal representation for its parent class, and so on. Following references from one internal class representation to another can be an expensive operation especially when the internal class representations have to be loaded in and out of the memory. This inefficiency significantly hinders the performance of JAVA™ virtual machines, especially those operating with limited memory and/or limited computing power (e.g., embedded systems).
In view of the foregoing, there is a need for improved techniques to perform type checking in JAVA™ computing environments.